<style>
.label-default {
    background-color: #f5f7fb;
	color: #999;
}
</style>
<div class="fui-page" ng-if="pagedata.op == 'main'">
	<div id="allmap" style="height:25rem;padding:0px 0px;width: 100%"></div>
	<div class="fui-cellone" style="padding:0;margin-top:-2.6rem">
			<div class="fui-cellone-text" style="width:12rem;padding:0.5rem;color:#fff;background:#cdab6a;border-top-right-radius:50rem;">
			<div class="text bold">{{pagedata.gong.jobinfo.title}}</div>
			<div>
			{{pagedata.gong.typetitle}}~{{pagedata.gong.paytypetitle}}~{{pagedata.gong.jobinfo.pay}}
			<span ng-if="pagedata.ismy==1" ng-click="pagedata.endsign(pagedata.gong);" class="r-f" style="padding-right:1rem;color:#fff"><i class="icon icon-zhifeiji"></i> 打卡下班</span>
			</div>
			</div>
	</div>
	<div ng-include="sys_html('common/_copyright',true)"></div>
	</div>
</div>
<script>
window.scope.location(function(res){
		if(!scope.pagedata.pcd.city){
			scope.pagedata.pcd=res.addressComponents
		}
		scope.pagedata.pcd.lat = res.lat_lng.lat;
		scope.pagedata.pcd.lng = res.lat_lng.lng;
		scope.pagedata.pcd.address = res.address;
		scope.pagedata.pcd.lat_lng = res.lat_lng;
		scope.tool.get_list('/maplog/getlist/signlogid='+scope.pagedata.signlog.id+'&lat='+scope.pagedata.pcd.lat+'&lng='+scope.pagedata.pcd.lng,true,function(res){
			require(['map'], function(BMap){
				var map = new BMap.Map("allmap");
				var list=res.list;
				var first=res.list[0];
				if(first){
					var point = new BMap.Point(first.lat_lng.lng, first.lat_lng.lat);
				}else{
					var point = new BMap.Point(scope.pagedata.pcd.lng, scope.pagedata.pcd.lat);
				}
				map.centerAndZoom(point, 13.6);
				// 编写自定义函数,创建标注
				function addMarker(point,icon){
					var marker = new BMap.Marker(point);
					var icon=new BMap.Icon(icon,new BMap.Size(26,26));
                    icon.setImageSize(new BMap.Size(26,26));
					marker.setIcon(icon);
					map.addOverlay(marker);
				}
				for (var i = 0; i < list.length; i ++) {
					var point = new BMap.Point(list[i].lat_lng.lng, list[i].lat_lng.lat);
					addMarker(point,list[i].iconPath,'32323232');
				}
			});
		});
});
scope.pagedata.endsign=function(item){
	scope.pagedata.nowitem=item;
	scope.confirm({
			'message':'确定打卡下班？',
			'success':function(){
				window.scope.location(function(res){
					console.log(res)
					if(res.lat_lng){
						scope.pagedata.nowitem.pcd=res.addressComponents
						scope.pagedata.nowitem.address=res.address
						scope.pagedata.nowitem.lat_lng=res.lat_lng
						scope.post_json('/gong/endsign/gongid='+item.id,scope.pagedata.nowitem);
					}else{
						scope.message('定位失败，打卡不成功！','error');
					}
				});
			},
			'fail':function(){}
	});
}
scope.pagedata.up=function(type){
	for(var i = 1;i<=100;i++){
		clearInterval(i);
	}
	var voicetime = 0;
    var upmaplog;
	if(scope.pagedata.signlog.endtime==0 && scope.pagedata.ismy==1){
		 upmaplog = setInterval(() => {
			if(!scope.pagedata.signlog.endtime>0){
				clearInterval(upmaplog);
				return false;
			}
			scope.post_json('/maplog/upmaplog/signlogid='+scope.pagedata.signlog.id,scope.pagedata.pcd,function(res){console.log(res)});
		}, 30000);
	}else{
		
	}
}
if(scope.pagedata.ismy==1){
	scope.pagedata.up();
}
</script>